<template>
  <div class="container">
    <!-- <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>项目建档</el-breadcrumb-item>
        </el-breadcrumb> -->
    <topTitle
      :titleText="titleText"
      :titleExplain="titleExplain"
      :back="type === 'bidding'"
      @gobackTriser="goBack"
    ></topTitle>
    <div class="mainCon">
      <el-form
        :model="formData"
        :rules="formRules"
        ref="formData"
        label-width="164px"
        class="demo-ruleForm"
      >
        <el-row>
          <el-col>
            <div class="secondaryTitle secondaryTitleTheme mrB30">
              项目基本信息
            </div>
          </el-col>
        </el-row>
        <el-row class="mrB8">
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="projectName" label="项目名称：">
                    <el-input
                      v-model.trim="formData.projectName"
                      placeholder="请输入项目完整名称"
                      class="proInputWidth"
                      clearable
                      filterable
                      @blur="validProName"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label="施工许可证："
                    :rules="
                      isNeedLicense == 0
                        ? [{ required: false }]
                        : formRules.license
                    "
                    prop="license"
                  >
                    <el-input
                      v-model.trim="formData.license"
                      placeholder="请输入施工许可证编号"
                      class="proInputWidth"
                      clearable
                      filterable
                      @blur="formData.license = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="projectStatus" label="项目状态：">
                    <el-select
                      clearable
                      filterable
                      placeholder="请选择"
                      class="proInputWidth"
                      v-model.trim="formData.projectStatus"
                    >
                      <el-option
                        v-for="item in projectStatus"
                        :key="item.code"
                        :label="item.name"
                        :value="item.code"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="areaId" label="所属区域：">
                    <el-cascader
                      ref="areas"
                      v-model="area"
                      :options="areasOptions"
                      @change="getAreaId"
                      clearable
                      filterable
                      placeholder="请选择"
                      class="proInputWidth"
                      :props="{ checkStrictly: false }"
                    ></el-cascader>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="industry" label="所属行业：">
                    <el-select
                      clearable
                      filterable
                      placeholder="请选择"
                      class="proInputWidth"
                      v-model="formData.industry"
                    >
                      <el-option
                        v-for="item in industryOptions"
                        :key="item.code"
                        :label="item.name"
                        :value="item.code"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="category" label="投资类别：">
                    <el-select
                      clearable
                      filterable
                      placeholder="请选择"
                      class="proInputWidth"
                      v-model="formData.category"
                    >
                      <el-option
                        v-for="item in investmentOptions"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="projectCost" label="工程造价：">
                    <el-input
                      v-model.trim="formData.projectCost"
                      placeholder="请输入工程造价"
                      class="minInputWidth"
                      clearable
                      @blur="formData.projectCost = changeValue($event)"
                    ></el-input
                    >元
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="startDate" label="开工日期：">
                    <el-date-picker
                      type="date"
                      placeholder="请选择"
                      v-model="formData.startDate"
                      value-format="yyyy-MM-dd"
                      class="proInputWidth"
                      clearable
                    ></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="constructionCycle" label="建设周期：">
                    <el-input
                      v-model.trim="formData.constructionCycle"
                      placeholder="请输入建设周期"
                      class="minInputWidth"
                      clearable
                      @blur="formData.constructionCycle = changeValue($event)"
                    ></el-input
                    >天
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    prop="detailAddress"
                    label="项目部详细地址："
                    :rules="
                      isNeedAddress == 0
                        ? [{ required: false }]
                        : formRules.detailAddress
                    "
                  >
                    <div style="position: relative">
                      <el-input
                        v-model.trim="formData.detailAddress"
                        placeholder="请输入项目部详细地址，并在地图上确定详细位置"
                        class="proInputWidth"
                        id="suggestId"
                        ref="inputDetailAdr"
                        @blur="hideMap"
                      ></el-input>
                      <!--@blur = "hideMap" -->
                      <div
                        style="
                          width: 62%;
                          height: 33px;
                          background: #fff;
                          position: absolute;
                          top: 3px;
                          left: 3px;
                          z-index: 10;
                          opacity: 0;
                        "
                        @click.stop.prevent="showMap"
                        v-if="isShowBox"
                        id="showBox"
                      ></div>
                      <div
                        id="searchResultPanel"
                        style="
                          border: 1px solid #c0c0c0;
                          width: 150px;
                          height: auto;
                          display: none;
                        "
                      ></div>
                    </div>
                    <el-row class="row-padding-bottom" v-if="isShowMap">
                      <el-col :span="24" class="col-position">
                        <div
                          id="l-map"
                          style="
                            height: 300px;
                            position: absolute;
                            width: 70%;
                            z-index: 1000;
                          "
                        ></div>
                      </el-col>
                    </el-row>

                    <!-- 获取当前地址  -->
                    <div id="allmap"></div>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="projectType" label="工程类型：">
                    <el-select
                      clearable
                      filterable
                      placeholder="请选择"
                      class="proInputWidth"
                      v-model="formData.projectType"
                    >
                      <el-option
                        v-for="item in projectType"
                        :key="item.code"
                        :label="item.name"
                        :value="item.code"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="!isWhUser()">
                  <el-form-item
                    prop="constructLocation"
                    label="施工地址："
                    :rules="
                      isNeedConstructLocation == 0
                        ? [{ required: false }]
                        : formRules.constructLocation
                    "
                  >
                    <el-input
                      v-model.trim="formData.constructLocation"
                      placeholder="请输入施工详细地址"
                      class="proInputWidth"
                      clearable
                      @blur="formData.constructLocation = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="isXiangYangUser()">
                  <el-form-item
                    label="合同签订日："
                    prop="contractSignDate"
                    :rules="
                      isNeedContractSignDate == 0
                        ? [{ required: false }]
                        : formRules.contractSignDate
                    "
                  >
                    <el-date-picker
                      type="date"
                      placeholder="请选择"
                      v-model="formData.contractSignDate"
                      value-format="yyyy-MM-dd"
                      class="proInputWidth"
                      clearable
                    ></el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="isWhUser()">
                  <el-form-item
                    prop="isStateOwnedConstruction"
                    label="是否国企施工项目："
                    :rules="
                      isNeedIsStateOwned == 0
                        ? [{ required: false }]
                        : formRules.isStateOwnedConstruction
                    "
                  >
                    <el-select
                      clearable
                      filterable
                      placeholder="请选择项目的施工总承包企业是否属于国有企业"
                      class="proInputWidth"
                      v-model="formData.isStateOwnedConstruction"
                    >
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row v-if="isWhUser()">
                <el-col :span="12">
                  <el-form-item
                    prop="constructLocation"
                    label="施工地址："
                    :rules="
                      isNeedConstructLocation == 0
                        ? [{ required: false }]
                        : formRules.constructLocation
                    "
                  >
                    <el-input
                      v-model.trim="formData.constructLocation"
                      placeholder="请输入施工详细地址"
                      class="proInputWidth"
                      clearable
                      @blur="formData.constructLocation = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row v-if="isWhUser()">
                <el-col :span="24">
                  <el-form-item
                    label="施工许可证："
                    class="upLoadDomContainer"
                    :rules="
                      isNeedLicenseFiles == 0
                        ? [{ required: false }]
                        : formRules.upLoadFileLicense
                    "
                    prop="upLoadFileLicense"
                  >
                    <uploadAnnex
                      @getFileList="getFileListLicense"
                      :limitationFactor="limitationFactorLicense"
                      @getFile="getFileLicense"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <uploadResult
                    style="margin-left: 120px"
                    :resultList="upLoadFileLicense"
                    @callBackResult="getFileLicense"
                  />
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item
                    label="开工令："
                    class="upLoadDomContainer"
                    :rules="
                      isNeedOrdFiles == 0
                        ? [{ required: false }]
                        : formRules.upLoadFileOrder
                    "
                    prop="upLoadFileOrder"
                  >
                    <uploadAnnex
                      @getFileList="getFileListOrder"
                      :limitationFactor="limitationFactorOrder"
                      @getFile="getFileOrder"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <!-- <elementImage :upLoadFile="upLoadFileOrder" :srcList="srcListOrder" :oldSrcList="oldSrcListOrder" @changeSrcList="changeSrcListOrder"></elementImage> -->
                  <uploadResult
                    style="margin-left: 120px"
                    :resultList="upLoadFileOrder"
                    @callBackResult="getFileOrder"
                  />
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col>
            <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
              建设方信息
            </div>
          </el-col>
        </el-row>
        <el-row class="mrB8">
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="companyNameJS" label="单位名称：">
                    <el-input
                      v-model.trim="formData.companyNameJS"
                      @change="
                        validUsccAndCompany(
                          formData.companyNameJS,
                          formData.usccJS
                        )
                      "
                      placeholder="请输入单位名称"
                      class="proInputWidth"
                      clearable
                      filterable
                      @blur="formData.companyNameJS = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="usccJS" label="统一社会信用代码：">
                    <el-input
                      v-model.trim="formData.usccJS"
                      @change="
                        validUsccAndCompany(
                          formData.companyNameJS,
                          formData.usccJS
                        )
                      "
                      placeholder="请输入统一社会信用代码"
                      class="proInputWidth"
                      clearable
                      filterable
                      @blur="formData.usccJS = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    prop="pcLeader"
                    :rules="
                      isNeedPcLeader == 0
                        ? [{ required: false }]
                        : formRules.pcLeader
                    "
                  >
                    <span slot="label">
                      项目负责人
                      <el-tooltip
                        content="Top center"
                        placement="top"
                        effect="dark"
                      >
                        <div slot="content">
                          业主单位负责该项目的人员，业主企业账号将发送至该人员的手机号
                        </div>
                        <i
                          class="icon iconfont iconhuabanfuben"
                        ></i> </el-tooltip
                      >：
                    </span>
                    <el-input
                      v-model.trim="formData.pcLeader"
                      placeholder="请输入项目全权负责人姓名"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label="负责人手机号码："
                    prop="pcLeaderTel"
                    :rules="
                      isNeedPcLeaderTel == 0
                        ? [{ required: false }]
                        : formRules.pcLeaderTel
                    "
                  >
                    <el-input
                      v-model.trim="formData.pcLeaderTel"
                      placeholder="请输入项目全权负责人手机号码"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col>
            <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
              施工方信息
            </div>
          </el-col>
        </el-row>
        <el-row class="mrB8">
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="companyNameSG" label="单位名称：">
                    <el-input
                      v-model.trim="formData.companyNameSG"
                      @change="
                        validUsccAndCompany(
                          formData.companyNameSG,
                          formData.usccSG
                        )
                      "
                      placeholder="请输入单位名称"
                      class="proInputWidth"
                      clearable
                      filterable
                      @blur="formData.companyNameSG = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="usccSG" label="统一社会信用代码：">
                    <el-input
                      v-model.trim="formData.usccSG"
                      @change="
                        validUsccAndCompany(
                          formData.companyNameSG,
                          formData.usccSG
                        )
                      "
                      placeholder="请输入统一社会信用代码"
                      class="proInputWidth"
                      clearable
                      filterable
                      @blur="formData.uscc = changeValue($event)"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    prop="leader"
                    :rules="
                      isNeedLeader == 0
                        ? [{ required: false }]
                        : formRules.leader
                    "
                  >
                    <span slot="label">
                      项目负责人
                      <el-tooltip
                        content="Top center"
                        placement="top"
                        effect="dark"
                      >
                        <div slot="content">
                          施工单位负责管理项目的人员，建档后项目账号将发送至负责人手机号
                        </div>
                        <i
                          class="icon iconfont iconhuabanfuben"
                        ></i> </el-tooltip
                      >：
                    </span>
                    <el-input
                      v-model.trim="formData.leader"
                      placeholder="请输入项目全权负责人姓名"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    prop="leaderTel"
                    label="负责人手机号码："
                    :rules="
                      isNeedLeaderTel == 0
                        ? [{ required: false }]
                        : formRules.leaderTel
                    "
                  >
                    <el-input
                      v-model.trim="formData.leaderTel"
                      placeholder="请输入项目全权负责人手机号码"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col>
            <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
              项目经理信息
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    prop="proManagerName"
                    label="项目经理姓名："
                    :rules="
                      isNeedManagerName == 1
                        ? formRules.proManagerName
                        : { required: false, trigger: 'blur' }
                    "
                  >
                    <el-input
                      v-model.trim="formData.proManagerName"
                      placeholder="请输入项目经理姓名"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    prop="proManagerCard"
                    label="项目经理身份证号："
                    :rules="
                      isNeedManagerIdcard == 0
                        ? [
                            {
                              required: false,
                              pattern:
                                /^(([1-9][0-9]{5}(19|20)[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}([0-9]|X|x))|([1-9][0-9]{5}[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}))$/,
                              message: '请输入正确的身份证号',
                              trigger: 'blur',
                            },
                          ]
                        : formRules.proManagerCard
                    "
                  >
                    <el-input
                      v-model.trim="formData.proManagerCard"
                      placeholder="请输入项目经理身份证号"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    prop="proManagerTel"
                    label="项目经理手机号："
                    :rules="
                      isNeedManagerTel == 0
                        ? [
                            {
                              required: false,
                              pattern: /^1[3456789]\d{9}$/,
                              message: '请输入正确的手机号码',
                              trigger: 'blur',
                            },
                          ]
                        : formRules.proManagerTel
                    "
                  >
                    <el-input
                      v-model.trim="formData.proManagerTel"
                      placeholder="请输入项目经理手机号"
                      class="proInputWidth"
                      clearable
                      filterable
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item
                    label="项目经理资格证书："
                    prop="managerUpLoadFile"
                    :rules="
                      isNeedMgFiles == 0
                        ? [{ required: false }]
                        : formRules.managerUpLoadFile
                    "
                  >
                    <uploadAnnex
                      @getFileList="getFileListManager"
                      :limitationFactor="limitationFactorManager"
                      @getFile="getFileManager"
                      :upLoadFile="managerUpLoadFile"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24" v-model="formData.managerImgUrl">
                  <!-- <elementImage :upLoadFile="managerUpLoadFile"   :srcList="managerSrcList" :oldSrcList="managerOldSrcList" @changeSrcList="changeManagerSrcList"></elementImage> -->
                  <uploadResult
                    style="margin-left: 120px"
                    :resultList="managerUpLoadFile"
                    @callBackResult="getFileManager"
                  />
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item
                    label="项目经理企业任命文件："
                    prop="manUploadFiles"
                    :rules="
                      isAppointJson == 0
                        ? [{ required: false }]
                        : formRules.manUploadFiles
                    "
                    class="manUploads"
                  >
                    <uploadAnnex
                      @getFileList="getFileListManFiles"
                      :limitationFactor="limitationFactorManFiles"
                      @getFile="getFileManFiles"
                      :upLoadFile="manUploadFiles"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24" v-model="formData.managerImgUrl">
                  <uploadResult
                    style="margin-left: 120px"
                    :resultList="manUploadFiles"
                    @callBackResult="getFileManFiles"
                  />
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col>
            <div class="secondaryTitle secondaryTitleTheme mrB30 mrT24">
              合同信息
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-row>
                <el-col :span="24">
                  <el-form-item
                    label="合同附件："
                    :rules="
                      isNeedUpLoadFile == 0
                        ? [{ required: false }]
                        : formRules.upLoadFile
                    "
                    prop="upLoadFile"
                  >
                    <uploadAnnex
                      @getFileList="getFileList"
                      :limitationFactor="limitationFactor"
                      @getFile="getFile"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24" v-model="formData.contractImgUrl">
                  <!-- <elementImage :upLoadFile="upLoadFile"   :srcList="srcList" :oldSrcList="oldSrcList" @changeSrcList="changeSrcList"></elementImage> -->
                  <uploadResult
                    style="margin-left: 120px"
                    :resultList="upLoadFile"
                    @callBackResult="getFile"
                  />
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
        <el-row style="text-align: center; margin-top: 40px">
          <el-col :span="20">
            <el-form-item style="margin-bottom: 16px">
              <el-button
                class="commonBut saveBtn"
                type="primary"
                @click="saveInfo"
                v-hasBtn="'projectBuild:add'"
                :loading="isSubmit"
                v-sdc
                >建档项目</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import common from '../../kits/common'
import { mapActions, mapState } from 'vuex'
export default {
  name: 'projectDocumentation',

  data() {
    //验证区域
    var checkArea = (rule, value, callback) => {
      if (!this.area || this.area.length < 1) {
        return callback(new Error('区域不能为空'))
      } else {
        callback()
      }
    }
    //   验证工程造价
    var validateProjectCost = (rule, value, callback) => {
      value = value.toString().replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('工程造价不能为空'))
      } else {
        var regCost = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/
        if (!regCost.test(value) || value == 0.0 || value == 0.0) {
          callback(new Error('工程造价范围格式不正确'))
        } else {
          callback()
        }
      }
    }
    // 验证建设周期
    var validateConCycle = (rule, value, callback) => {
      value = value.toString().replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('建设周期不能为空'))
      } else {
        var ConCycle = /^\+?[1-9][0-9]*$/
        if (!ConCycle.test(value)) {
          callback(new Error('建设周期格式不正确'))
        } else {
          callback()
        }
      }
    }
    //验证企业名称
    var validateName = (rule, value, callback) => {
      value = value.toString().replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('企业名称不能为空'))
      } else {
        if (value.length > 100) {
          callback(new Error('企业名称不能超过100个字符'))
        } else {
          if (rule.field === 'companyNameJS') {
            if (this.formData.usccJS !== '') {
              this.$refs.formData.validateField('usccJS')
            }
          } else {
            if (this.formData.usccSG !== '') {
              this.$refs.formData.validateField('usccSG')
            }
          }
          callback()
        }
      }
    }
    //验证uscc
    var validateUscc = (rule, value, callback) => {
      value = value.toString().replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('统一社会信用代码不能为空'))
      } else {
        var regUscc = /^[0-9A-Z]{2}[0-9]{6}[0-9A-Z]{10}$/
        if (!regUscc.test(value)) {
          callback(new Error('统一社会信用代码格式不正确'))
        } else {
          callback()
          //   var companyName = "";
          //   if (rule.field === "usccJS") {
          //     companyName = this.formData.companyNameJS;
          //     if (this.jsFlag == "") {
          //       this.validUscc(companyName, rule.field, value, callback);
          //     } else {
          //       if (
          //         (this.jsName != companyName ||
          //           this.jsUscc != value ||
          //           this.jsFlag == "2") &&
          //         this.saveFlag == "1"
          //       ) {
          //         this.validUscc(companyName, rule.field, value, callback);
          //       } else {
          //         callback();
          //       }
          //     }
          //   } else {
          //     companyName = this.formData.companyNameSG;
          //     if (this.sgFlag == "") {
          //       this.validUscc(companyName, rule.field, value, callback);
          //     } else {
          //       if (
          //         (this.sgName != companyName ||
          //           this.sgUscc != value ||
          //           this.sgFlag == "2") &&
          //         this.saveFlag == "1"
          //       ) {
          //         this.validUscc(companyName, rule.field, value, callback);
          //       } else {
          //         callback();
          //       }
          //     }
          //   }
        }
      }
    }
    var validAddress = (rule, value, callback) => {
      var that = this
      var address = that.formData.detailAddress.replace(/\s/g, '')
      setTimeout(function () {
        if (!that.lat || !address || (that.flag == false && !that.lat)) {
          that.flag = true
          return callback(new Error('请输入有效地址'))
        } else {
          callback()
        }
      }, 800)
    }
    var validateConAddress = (rule, value, callback) => {
      value = value.toString().replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('请输入施工地址'))
      } else {
        if (value.length > 50) {
          callback(new Error('施工地址最多可输入50字'))
        } else {
          callback()
        }
      }
    }
    var checkUpLoadFileOrder = (rule, value, callback) => {
      if (this.upLoadFileOrder.length == 0) {
        return callback(new Error('请上传开工令附件'))
      } else {
        callback()
      }
    }
    // 武汉施工许可证
    var checkUpLoadFileLicense = (rule, value, callback) => {
      if (this.upLoadFileLicense.length == 0) {
        return callback(new Error('请上传施工许可证'))
      } else {
        callback()
      }
    }
    // 合同附件
    var checkUpLoadFile = (rule, value, callback) => {
      if (this.upLoadFile.length == 0) {
        return callback(new Error('请上传合同附件'))
      } else {
        callback()
      }
    }
    var validateManagerUpLoadFile = (rele, value, callback) => {
      if (this.managerUpLoadFile.length < 1) {
        return callback(new Error('必须上传项目经理资格证书'))
      } else {
        callback()
      }
    }
    var validateManUploadFiles = (rule, value, callback) => {
      if (this.manUploadFiles.length == 0) {
        return callback(new Error('请上传项目经理企业任命文件'))
      } else {
        callback()
      }
    }
    return {
      // 施工许可证
      limitationFactorLicense: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'license', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'licenseForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传施工许可证，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 开工令
      limitationFactorOrder: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'startOrder', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'startOrderForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传开工令，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      limitationFactor: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'salaryExcel', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'salaryExcelForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传项目合同（必须包含项目名称、甲乙双方、工程造价、工期等必要内容），附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 项目经理资格证书
      limitationFactorManager: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传文件最大数量设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'managerFiles', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'managerFilesForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传项目项目经理资质证书，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      // 任命书
      limitationFactorManFiles: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传附件的个数设置
        fileSize: 5, //自定义上传文件最大设置
        formatType: 'typeFour', //自定义上传格式校验类型
        fileId: 'manUploadFiles', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'manFilesForm', //自定义id解决一个页面包含多个上传附件
        messagetip:
          '要求格式为png，jpg，jpeg，doc，docx，xls，xlsx，pdf格式，附件大小不超过5M', //自定义报错提示语
        methodTip:
          '请上传项目经理任命书，附件格式支持png，jpg，jpeg，doc，docx，xls，xlsx，pdf，最多上传10个附件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      titleText: '项目建档',
      titleExplain:
        '工程项目可由监管部门进行建档，建档完成后相关施工方及建设方即可管理该项目',
      // formData: {
      //   employeeName: ""
      // },
      projectStatus: [],
      formData: {
        projectName: '',
        license: '',
        projectStatus: '',
        areaId: '',
        industry: '',
        category: '',
        projectCost: '',
        startDate: '',
        constructionCycle: '',
        projectType: '',
        uscc: '',
        detailAddress: '',
        companyNameJS: '', //建设方
        companyNameSG: '', //施工方
        usccJS: '', //建设方
        usccSG: '', //建设方
        leader: '',
        leaderTel: '',
        pcLeader: '', //建设方项目负责人
        pcLeaderTel: '', //建设方项目负责人电话
        contractImgUrl: [], //合同附件
        constructLocation: '', //施工地址
        isStateOwnedConstruction: '',
        contractSignDate: '',
        proManagerName: '', //项目经理姓名
        proManagerCard: '', //项目经理身份证号
        proManagerTel: '', //项目经理手机号
        managerImgUrl: [], //项目经理资质附件
      },
      options: [
        {
          value: 'HTML',
          label: '超文本标签',
        },
        {
          value: 'CSS',
          label: '层叠样式表',
        },
        {
          value: 'JavaScript',
          label: 'js编程语言',
        },
      ],
      upLoadFile: [], //附件
      srcList: [],
      oldSrcList: [],
      upLoadFileLicense: [], //施工许可证附件
      srcListLicense: [],
      oldSrcListLicense: [],
      upLoadFileOrder: [], //开工令附件
      srcListOrder: [],
      oldSrcListOrder: [],
      managerUpLoadFile: [], //项目经理资质附件
      managerSrcList: [],
      managerOldSrcList: [],
      manFilesOldSrcList: [], //任命书
      manFilesSrcList: [],
      manUploadFiles: [],
      formRules: {
        projectName: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' },
        ],
        pcLeader: [
          { required: true, message: '请输入项目负责人', trigger: 'blur' },
        ],
        pcLeaderTel: [
          { required: true, message: '请输入负责人手机号码', trigger: 'blur' },
        ],
        projectStatus: [
          { required: true, message: '项目状态不能为空', trigger: 'change' },
        ],
        areaId: [{ required: true, validator: checkArea, trigger: 'change' }],
        industry: [
          { required: true, message: '所属行业不能为空', trigger: 'change' },
        ],
        category: [
          { required: true, message: '投资类别不能为空', trigger: 'change' },
        ],
        projectCost: [
          { required: true, validator: validateProjectCost, trigger: 'blur' },
        ],
        startDate: [
          { required: true, message: '开工日期不能为空', trigger: 'change' },
        ],
        constructionCycle: [
          { required: true, validator: validateConCycle, trigger: 'blur' },
        ],
        projectType: [
          { required: true, message: '工程类型不能为空', trigger: 'change' },
        ],
        companyNameJS: [
          { required: true, validator: validateName, trigger: 'blur' },
        ],
        companyNameSG: [
          { required: true, validator: validateName, trigger: 'blur' },
        ],
        usccJS: [
          { required: true, validator: validateUscc, trigger: 'change' },
        ],
        usccSG: [
          { required: true, validator: validateUscc, trigger: 'change' },
        ],
        detailAddress: [
          { required: true, validator: validAddress, trigger: 'blur' },
        ],
        leader: [
          {
            required: true,
            message: '项目全权负责人姓名不能为空',
            trigger: 'blur',
          },
        ],
        leaderTel: [
          {
            required: true,
            pattern: /^1[3456789]\d{9}$/,
            message: '请输入正确的手机号码',
            trigger: 'blur',
          },
        ],
        constructLocation: [
          { required: true, validator: validateConAddress, trigger: 'blur' },
        ],
        isStateOwnedConstruction: [
          {
            required: true,
            message: '请选择项目的施工总承包企业是否属于国有企业',
            trigger: 'change',
          },
        ],
        upLoadFileOrder: [
          {
            required: true,
            validator: checkUpLoadFileOrder,
            trigger: 'blur',
          },
        ],
        contractSignDate: [
          { required: true, message: '请选择合同签订日', trigger: 'change' },
        ],
        license: [
          { required: true, message: '请输入施工许可证编号', trigger: 'blur' },
        ],
        upLoadFileLicense: [
          {
            required: true,
            validator: checkUpLoadFileLicense,
            trigger: 'blur',
          },
        ],
        upLoadFile: [
          {
            required: true,
            validator: checkUpLoadFile,
            trigger: 'blur',
          },
        ],
        proManagerName: [
          { required: true, message: '项目经理姓名不能为空', trigger: 'blur' },
        ],
        proManagerCard: [
          {
            required: true,
            pattern:
              /^(([1-9][0-9]{5}(19|20)[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}([0-9]|X|x))|([1-9][0-9]{5}[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}))$/,
            message: '请输入正确的身份证号',
            trigger: 'blur',
          },
        ],
        proManagerTel: [
          {
            required: true,
            pattern: /^1[3456789]\d{9}$/,
            message: '请输入正确的手机号码',
            trigger: 'blur',
          },
        ],
        managerUpLoadFile: [
          {
            required: true,
            validator: validateManagerUpLoadFile,
            trigger: 'change',
          },
        ],
        manUploadFiles: [
          {
            required: true,
            validator: validateManUploadFiles,
            trigger: 'change',
          },
        ],
      },
      isShowMap: false, //是否显示地图
      lon: '',
      lat: '',
      LocationPoint: '',
      isShowBox: true,
      selectData: '',
      projectType: [], //工程类型
      category: [], //投资类别
      area: [],
      isSubmit: false, //保存点击事件
      jsFlag: '',
      sgFlag: '',
      jsName: '',
      jsUscc: '',
      sgName: '', //建设方
      sgUscc: '', //建设方
      //   saveFlag: "1",
      // isShowAdd:"",
      flag: true,
      type: '',
      id: '',
      list: [],
      isNeedLicense: '', //施工许可证
      isNeedOrdFiles: '', //开工令附件
      isNeedUpLoadFile: '', //合同附件
      isNeedIsStateOwned: '', //是否国企施工项目
      isAppointJson: '',
      isNeedContractSignDate: '', //合同签订日
      isNeedLicenseFiles: '', //武汉施工许可证,
      isNeedAddress: '', //详细地址
      isNeedConstructLocation: '', //施工地址
      isNeedPcLeader: '', //建设方负责人
      isNeedPcLeaderTel: '', //建设方负责人手机号
      isNeedLeader: '',
      isNeedLeaderTel: '',
      isNeedManagerName: '',
      isNeedManagerIdcard: '',
      isNeedManagerTel: '',
      isNeedMgFiles: '',
    }
  },
  computed: {
    ...mapState(['areasOptions', 'industryOptions', 'investmentOptions']),
  },
  async created() {
    await this.getIsNeed() //是否必填
    this.getAreas({ areaId: this.$store.state.areaInfoArr.areaId })
    this.getSelecData('PROJECT_STATUS') //项目状态
    // this.getSelecData("INDUSTRY"); //所属行业
    this.getSelecData('PROJECT_INVESTMENT') //投资类别
    this.getSelecData('PROJECT_TYPE') //工程类型
    //获取行业
    this.getIndustry({})
    this.type = this.$route.query.type
    this.id = this.$route.query.id
    if (this.type === 'bidding') {
      this.titleText = '补充项目信息'
      this.titleExplain =
        '根据招标局推送的已中标项目信息，补充其他重要信息后，为该项目建档'
      this.getTitleData()
    } else {
      this.$store.state.activeMenu =
        '/home/monitorProjectManagement/projectDocumentation'
    }
  },
  mounted() {
    if (!this.isWhUser()) {
      // delete this.formRules.isStateOwnedConstruction
    }
    this.$nextTick(function () {
      this.getLocation()
    })
  },
  methods: {
    getTitleData() {
      this.axios({
        method: 'post',
        data: { id: this.id },
        url: 'api-p/project/tender/base/detailbyid',
      })
        .then((response) => {
          if (!response.data.hasError) {
            const { result } = response.data
            this.formData.projectName = result.projectName
            this.area = result.areaList
            this.formData.areaId = result.areaId
            this.formData.industry = result.industryId
            this.formData.projectCost = result.total
            this.formData.constructionCycle = result.timeLimitDescription
            this.formData.leaderTel = result.leaderTel
          } else {
            this.$message.error(response.data.errorMsg)
          }
        })
        .catch((error) => {
          if (error.response) {
            this.$message.error(error.response.data)
          }
        })
    },
    changeName(val) {
      console.log(val)
    },
    ...mapActions(['getAreas', 'getIndustry']),
    /**
     * @description: 获取上传的附件
     */
    getFileListLicense(val) {
      this.oldSrcListLicense.push(val)
      this.srcListLicense.push(val)
    },
    getFileList(val) {
      this.oldSrcList.push(val)
      this.srcList.push(val)
    },
    getFileListOrder(val) {
      this.oldSrcListOrder.push(val)
      this.srcListOrder.push(val)
    },
    /**
     * @description: 获取上传的附件
     */
    getFile(val) {
      this.upLoadFile = val
    },
    getFileLicense(val) {
      this.upLoadFileLicense = val
    },
    getFileOrder(val) {
      this.upLoadFileOrder = val
    },
    getFileListManager(val) {
      this.managerOldSrcList.push(val)
      this.managerSrcList.push(val)
    },
    getFileManager(val) {
      this.managerUpLoadFile = val
    },
    // 项目经理任命书
    getFileListManFiles(val) {
      this.manFilesOldSrcList.push(val)
      this.manFilesSrcList.push(val)
    },
    getFileManFiles(val) {
      this.manUploadFiles = val
    },
    // 验证uscc
    // validUscc(companyName, field, value, callback) {
    //   this.axios({
    //     method: "post",
    //     url: "api-c/companyaudit/base/validcompanybyproject",
    //     data: {
    //       name: companyName.replace(/\s+/g, ""),
    //       uscc: value
    //     }
    //   })
    //     .then(res => {
    //       if (!res.data.hasError) {
    //         if (field == "usccJS") {
    //           this.jsFlag = "1";
    //           this.jsName = companyName;
    //           this.jsUscc = value;
    //         }
    //         if (field == "usccSG") {
    //           this.sgFlag = "1";
    //           this.sgName = companyName;
    //           this.sgUscc = value;
    //         }

    //         callback();
    //       } else {
    //         if (field == "usccJS") {
    //           this.jsFlag = "2";
    //           this.jsName = companyName;
    //           this.jsUscc = value;
    //         }
    //         if (field == "usccSG") {
    //           this.sgFlag = "2";
    //           this.sgName = companyName;
    //           this.sgUscc = value;
    //         }
    //         callback(new Error(res.data.errorMsg));
    //       }
    //     })
    //     .catch(error => {
    //       callback(new Error("验证失败"));
    //     });
    // },
    validUsccAndCompany(companyName, uscc) {
      if (companyName && uscc) {
        this.axios({
          method: 'post',
          url: 'api-c/companyaudit/base/validcompanybyproject',
          data: {
            name: companyName.replace(/\s+/g, ''),
            uscc: uscc.replace(/\s+/g, ''),
          },
        })
          .then((res) => {
            if (!res.data.hasError) {
              this.$message({
                message: '已通过校验',
                type: 'success',
              })
            } else {
              if (res.data.errorCode == 'unmatched') {
                this.$message({
                  message: '未通过校验，请确认信息是否准确',
                  type: 'warning',
                })
              }
            }
          })
          .catch((error) => {
            this.$message.error('验证失败')
          })
      }
    },
    getLocation() {
      var that = this
      var map = new BMap.Map('allmap')

      function myFun(result) {
        var cityName = result.name
        map.setCenter(cityName)
        that.LocationPoint = cityName
      }
      var myCity = new BMap.LocalCity()
      myCity.get(myFun)
    },
    showMap() {
      this.isShowMap = true
      this.isShowBox = false
      var addressName = this.formData.detailAddress
      this.$nextTick(function () {
        // 详细地址获取焦点
        this.$refs.inputDetailAdr.focus()
        this.initMap()
        setTimeout(function () {
          if ($('.tangram-suggestion-main').length == 1) {
            $('#suggestId').val(addressName)
          }
        }, 50)
        $('#suggestId').val(addressName)
      })
    },
    hideMap() {
      var that = this
      that.$refs.inputDetailAdr.blur()
      setTimeout(function () {
        if (that.selectData == '1') {
          that.isShowMap = true
          that.selectData = ''
          that.isShowBox = false
          //  that.initMap();
        } else {
          that.isShowMap = false
          that.isShowBox = true
        }
      }, 500)
    },
    initMap() {
      var that = this
      // 百度地图API功能
      function G(id) {
        return document.getElementById(id)
      }

      var map = new BMap.Map('l-map')
      if (that.formData.detailAddress) {
        that.isShowMap = true
        this.isShowBox = false

        var point = new BMap.Point(that.lon, that.lat)

        map.centerAndZoom(point, 16)

        var mk = new BMap.Marker(point)
        map.addOverlay(mk)
        map.panTo(point)
        // 初始化可拖拽
        mk.enableDragging()
        mk.addEventListener('dragend', function (e) {
          that.lon = e.point.lng
          that.lat = e.point.lat
          var myGeo = new BMap.Geocoder()
          // 根据坐标得到地址描述
          myGeo.getLocation(
            new BMap.Point(e.point.lng, e.point.lat),
            function (result) {
              if (result) {
                that.formData.detailAddress = result.address
              }
            }
          )
        })
      } else {
        var myGeo = new BMap.Geocoder()
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint(
          that.LocationPoint,
          function (point) {
            if (point) {
              map.centerAndZoom(point, 16)
              var mk = new BMap.Marker(point)
              map.addOverlay(mk)
              map.panTo(point)
              mk.enableDragging()
              mk.addEventListener('dragend', function (e) {
                that.lon = e.point.lng
                that.lat = e.point.lat
                var myGeo = new BMap.Geocoder()
                // 根据坐标得到地址描述
                myGeo.getLocation(
                  new BMap.Point(e.point.lng, e.point.lat),
                  function (result) {
                    if (result) {
                      that.formData.detailAddress = result.address
                    }
                  }
                )
              })
            } else {
              // alert("您选择地址没有解析到结果!");
            }
          },
          '北京市'
        )
      }
      //增加滚轮放大缩小
      map.enableScrollWheelZoom(true)

      //增加滚轮放大缩小
      var ac = new BMap.Autocomplete({
        //建立一个自动完成的对象
        input: 'suggestId',
        location: map,
      })

      ac.addEventListener('onhighlight', function (e) {
        // that.selectData = "1"
        //鼠标放在下拉列表上的事件
        var str = ''
        var _value = e.fromitem.value
        var value = ''
        if (e.fromitem.index > -1) {
          value =
            _value.province +
            _value.city +
            _value.district +
            _value.street +
            _value.business
        }
        str =
          'FromItem<br />index = ' + e.fromitem.index + '<br />value = ' + value

        value = ''
        if (e.toitem.index > -1) {
          _value = e.toitem.value
          value =
            _value.province +
            _value.city +
            _value.district +
            _value.street +
            _value.business
        }
        str +=
          '<br />ToItem<br />index = ' +
          e.toitem.index +
          '<br />value = ' +
          value
        G('searchResultPanel').innerHTML = str
      })

      var myValue
      ac.addEventListener('onconfirm', function (e) {
        that.selectData = '1'
        var suggestVal = $('#suggestId').val()
        $('#suggestId').bind('input propertychange', function () {
          if (that.formData.detailAddress != suggestVal) {
            that.flag = false
            that.lon = ''
            that.lat = ''
          }
        })
        //鼠标点击下拉列表后的事件
        var _value = e.item.value
        myValue =
          _value.province +
          _value.city +
          _value.district +
          _value.street +
          _value.business
        G('searchResultPanel').innerHTML =
          'onconfirm<br />index = ' +
          e.item.index +
          '<br />myValue = ' +
          myValue
        that.formData.detailAddress = myValue
        setPlace()
      })

      function setPlace() {
        map.clearOverlays() //清除地图上所有覆盖物
        function myFun() {
          var pp = local.getResults().getPoi(0).point //获取第一个智能搜索的结果
          map.centerAndZoom(pp, 18)
          var marker = new BMap.Marker(pp)
          map.addOverlay(marker) //添加标注
          that.lon = pp.lng
          that.lat = pp.lat
          var geoc = new BMap.Geocoder()
          marker.enableDragging()
          marker.addEventListener('dragend', function (e) {
            that.lon = e.point.lng
            that.lat = e.point.lat
            var myGeo = new BMap.Geocoder()
            // 根据坐标得到地址描述
            myGeo.getLocation(
              new BMap.Point(e.point.lng, e.point.lat),
              function (result) {
                if (result) {
                  that.formData.detailAddress = result.address
                }
              }
            )
          })
        }
        var local = new BMap.LocalSearch(map, {
          //智能搜索
          onSearchComplete: myFun,
        })
        local.search(myValue)
        // that.$refs.inputDetailAdr.focus();
      }
    },
    getSelecData(type) {
      var url
      if (type == 'PROJECT_INVESTMENT' || type == 'PROJECT_STATUS') {
        url = 'api-p/project/expand/findstatusbytype'
      } else {
        url = 'api-bs/base/dicitem/findbytype'
      }
      this.axios({
        method: 'post',
        url: url,
        data: { type: type },
      })
        .then((res) => {
          if (type == 'PROJECT_TYPE') {
            this.projectType = res.data.result
          } else if (type == 'PROJECT_INVESTMENT') {
            this.category = res.data.result
          } else if (type == 'PROJECT_STATUS') {
            this.projectStatus = res.data.result
          }
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取数据失败',
            type: 'error',
          })
        })
    },
    //获取选中的区域最后一级id
    getAreaId() {
      this.formData.areaId = this.area[this.area.length - 1]
    },

    ajaxSubmit() {
      let data = {
        projectName: this.formData.projectName, //项目名称
        license: this.formData.license, //施工许可证
        status: this.formData.projectStatus, //项目状态
        areaId: this.formData.areaId, //所属区域
        industryId: this.formData.industry, //所属行业
        investment: this.formData.category, //投资类别
        total: this.formData.projectCost, //工程造价
        startDate: this.formData.startDate, //开工日期
        cycle: this.formData.constructionCycle, //建设周期
        address: this.formData.detailAddress, //详细地址
        typeId: this.formData.projectType, //工程类型
        pcName: this.formData.companyNameJS.replace(/\s+/g, ''), //建设方单位名称
        pcUscc: this.formData.usccJS.replace(/\s+/g, ''), //建设方统一社会信用代码
        pbName: this.formData.companyNameSG.replace(/\s+/g, ''), //施工方单位名称
        pbUscc: this.formData.usccSG.replace(/\s+/g, ''), //施工方统一社会信用代码,
        lon: this.lon, //经度
        lat: this.lat, //纬度
        leader: this.formData.leader, //---项目负责人
        leaderTel: this.formData.leaderTel, //---项目负责人电话
        pcLeader: this.formData.pcLeader,
        pcLeaderTel: this.formData.pcLeaderTel,
        files: JSON.stringify(this.upLoadFile), //---项目合同附件
        licenseFiles: JSON.stringify(this.upLoadFileLicense), //施工许可证
        ordFiles: JSON.stringify(this.upLoadFileOrder), //---开工令附件
        constructLocation: this.formData.constructLocation,
        contractSignDate: this.formData.contractSignDate,
        // 新增项目经理信息字段
        managerName: this.formData.proManagerName,
        managerIdcard: this.formData.proManagerCard,
        managerTel: this.formData.proManagerTel,
        mgFiles: JSON.stringify(this.managerUpLoadFile), //项目经理资格证书
        appointJson: JSON.stringify(this.manUploadFiles),
      }
      if (this.type === 'bidding') {
        Object.assign(data, { projectTenderId: this.$route.query.id })
      }
      // if(this.isWhUser()){
      data.isStateOwnedConstruction = this.formData.isStateOwnedConstruction
      // }
      this.axios({
        method: 'post',
        url: 'api-p/project/expand/addbymonitor',
        data,
      })
        .then((res) => {
          if (!res.data.hasError) {
            this.$confirm('该项目已完成建档，系统已通知至企业', '建档成功', {
              confirmButtonText: '去看看',
              cancelButtonText: '继续建档',
              type: 'success',
              center: true,
            })
              .then(() => {
                // 点击去看看按钮则跳转至该项目的详情页面
                // this.addProjectInfoTab();
                this.clearForm()
                this.$nextTick(function () {
                  this.$router.push({
                    path: '/home/monitorProjectManagement/projectDetail',
                    name: 'projectDetail',
                    query: {
                      projectId: res.data.result,
                      type: 'projectDetail',
                    },
                  })
                  this.$store.commit('CHANGE_SLIDER_NAME', {
                    oldUrl: '/home/project/projectList',
                    newUrl: this.$router.currentRoute.fullPath,
                  })
                })
              })
              .catch(() => {
                // this.formData.license = "";
                // this.formData.pcLeaderTel="";
                // this.formData.pcLeader="";
                // this.area = "";
                // this.upLoadFile = [];
                // this.$refs["formData"].resetFields();
                this.clearForm()
              })
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.errorMsg,
              type: 'error',
            })
          }
          this.isSubmit = false
        })
        .catch((res) => {
          //   this.saveFlag = "1";
          this.isSubmit = false
          this.$message.error('数据获取失败')
        })
    },
    clearForm() {
      this.formData.license = ''
      this.formData.pcLeaderTel = ''
      this.formData.pcLeader = ''
      this.area = ''
      this.upLoadFile = []
      this.upLoadFileOrder = []
      this.managerUpLoadFile = []
      this.manUploadFiles = []
      this.formData.contractSignDate = ''
      this.$refs['formData'].resetFields()
    },
    saveInfo() {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.showTip()
        } else {
          return false
        }
      })
    },
    showTip() {
      this.$confirm(
        '系统将根据施工方、建设方的项目负责人姓名和手机号，自动创建项目账号，并短信通知项目负责人和施工企业',
        '项目账号',
        {
          dangerouslyUseHTMLString: true,
          type: 'warning',
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }
      )
        .then((action) => {
          this.isSubmit = true
          this.ajaxSubmit()
        })
        .catch(() => {})
    },
    // saveInfoTip(){
    //       this.$confirm("系统将根据施工方的项目负责人姓名和手机号，自动创建项目账号，并短信通知项目负责人和施工企业", "项目账号", {
    //           cancelButtonClass: "btn-custom-cancel",
    //           type: "warning"
    //       })
    //       .then(() => {
    //         //   this.saveInfo();
    //         this.$refs["formData"].validate(valid => {
    //             if (valid) {
    //                 this.isSubmit = true;
    //                 this.ajaxSubmit();
    //             }
    //         })
    //       })
    //   },
    // saveInfo() {
    //   this.isSubmit = true;
    //   this.saveFlag = "2";
    //   if (this.jsFlag == "2" || this.sgFlag == "2") {
    //     this.$message({
    //       showClose: true,
    //       duration: 3000,
    //       message: "企业名称与统一社会信用代码不匹配",
    //       type: "error"
    //     });
    //     this.isSubmit = false;
    //     this.saveFlag = "1";
    //     return;
    //   }

    //   this.$refs["formData"].validate(valid => {
    //     if (valid) {
    //       this.saveFlag = "1";
    //       this.ajaxSubmit();
    //     } else {
    //       this.saveFlag = "1";
    //       this.selectData = "";
    //       this.isSubmit = false;
    //       return false;
    //     }
    //   });

    //   });
    // },
    validProName() {
      if (this.formData.projectName) {
        this.axios({
          method: 'post',
          url: 'api-p/projectapplication/expand/check',
          data: { projectName: this.formData.projectName },
        })
          .then((resp) => {
            if (resp.data.hasError) {
              this.$message({
                showClose: true,
                duration: 3000,
                message: resp.data.errorMsg,
                type: 'error',
              })
            }
          })
          .catch((resp) => {
            this.$message.error('数据获取失败')
          })
      }
    },
    /**
     * @description: 改变图片地址
     */
    changeSrcList(val) {
      this.srcList = val
    },
    changeSrcListOrder(val) {
      this.srcListOrder = val
    },
    goBack() {
      this.$router.push({
        path: '/home/projectDeduplication/projectInterfaceDetail',
        name: 'projectInterfaceDetail',
        query: {
          id: this.id,
          type: this.type,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/dataDocking/biddingProjectList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    // 获取是否必填数据
    getIsNeed() {
      return this.axios({
        method: 'post',
        url: 'api-m/fieldconfig/base/getbymaintype',
        data: {
          mainType: 'PROJECT_BUILD',
        },
      })
        .then((response) => {
          if (!response.data.hasError) {
            this.list = response.data.result
            // this.$set(this.listObject,'isNeedManagerTel',element.isNeed)
            this.list.forEach((element) => {
              if (element.code == 'license') {
                //施工许可证
                this.isNeedLicense = element.isNeed
              } else if (element.code == 'ordFiles') {
                //开工令附件
                this.isNeedOrdFiles = element.isNeed
              } else if (element.code == 'isStateOwnedConstruction') {
                //是否国企施工项目
                this.isNeedIsStateOwned = element.isNeed
              } else if (element.code == 'contractSignDate') {
                //合同签订日
                this.isNeedContractSignDate = element.isNeed
              } else if (element.code == 'licenseFiles') {
                //武汉施工许可证
                this.isNeedLicenseFiles = element.isNeed
              } else if (element.code == 'files') {
                //合同附件
                this.isNeedUpLoadFile = element.isNeed
              } else if (element.code == 'managerName') {
                //项目经理姓名
                this.isNeedManagerName = element.isNeed
              } else if (element.code == 'managerIdcard') {
                //项目经理身份证号managerIdcard
                this.isNeedManagerIdcard = element.isNeed
              } else if (element.code == 'managerTel') {
                //项目经理手机号码
                this.isNeedManagerTel = element.isNeed
              } else if (element.code == 'mgFiles') {
                //项目经理资格证书
                this.isNeedMgFiles = element.isNeed
              } else if (element.code == 'appointJson') {
                //项目经理任命文件
                this.isAppointJson = element.isNeed
              } else if (element.code == 'address') {
                this.isNeedAddress = element.isNeed
              } else if (element.code == 'constructLocation') {
                this.isNeedConstructLocation = element.isNeed
              } else if (element.code == 'pcLeader') {
                this.isNeedPcLeader = element.isNeed
              } else if (element.code == 'pcLeaderTel') {
                this.isNeedPcLeaderTel = element.isNeed
              } else if (element.code == 'leader') {
                this.isNeedLeader = element.isNeed
              } else if (element.code == 'leaderTel') {
                this.isNeedLeaderTel = element.isNeed
              }
            })
          } else {
            this.$message.error(response.data.errorMsg)
          }
        })
        .catch((error) => {
          if (error.response) {
            this.$message.error(error.response.data)
          }
        })
    },
  },
  watch: {
    'formData.detailAddress': {
      handler(newVal, oldVal) {
        if (oldVal) {
          if (newVal != oldVal) {
            // this.lon = "";
            // this.lat = "";
          }
        }
      },
      deep: true,
    },
  },
}
</script>

<style lang="less" scoped>
.container {
  .mainCon {
    background: #fff;
    padding: 24px;
    top: 210px;
    .infoTitle {
      font-size: 16px;
      padding: 16px 24px;
      background: #f5f7fb;
      margin-bottom: 24px;
      color: #333;
      font-weight: 700;
    }
    .proInputWidth {
      width: 75%;
    }
    .minInputWidth {
      width: 35%;
      margin-right: 8px;
    }
  }
  .uploadBox {
    position: relative;
    .uploadImg {
      width: 96px;
      height: 36px;
      color: #009588;
      border: 1px solid #009588;
      line-height: 10px;
    }
    .uploadImgState {
      font-size: 14px;
      color: #999999;
      margin-left: 12px;
    }
    .upLoadDom {
      position: absolute;
      top: 0;
      left: 0;
      opacity: 0;
      input {
        width: 100px;
        height: 36px;
        cursor: pointer;
      }
    }
  }
  .imgStyle {
    padding-left: 100px;
    margin-top: 24px;
    li {
      position: relative;
      margin-right: 20px;
      margin-top: 10px;
      i {
        position: absolute;
        right: -6px;
        top: -10px;
        font-size: 20px;
      }
    }
  }
  .manUploads {
    /deep/ .el-form-item__label {
      line-height: normal !important;
    }
  }
}
</style>
